package com.dily.study.demo.struct.Tree;

import com.dily.study.demo.struct.demo.TreeNode;
import org.apache.poi.ss.formula.functions.T;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * Date: 2022-08-17 星期三
 * Time: 15:16
 * Author: Dily_Su
 * Remark: 树
 */
public class TreeDemo {


    public static void main(String[] args) {

//        TreeNode.preOrder(createTree());
//        TreeNode.middleOrder(createTree());
        TreeNode<String> root = new TreeNode<String>("").createTree(Arrays.asList("A", "B", "C", "D", "E", "F"));
        TreeNode<String> node = new TreeNode<>("G");
        root.addNode(root, node);
        TreeNode.postOrder(root);
    }


    public static void test() {
        TreeNode<String> root = new TreeNode<>("A");
        root.setDeep(1);
        TreeNode<String> B = new TreeNode<>("B");
        TreeNode<String> C = new TreeNode<>("C");
        TreeNode<String> D = new TreeNode<>("D");
        TreeNode<String> E = new TreeNode<>("E");
        TreeNode<String> F = new TreeNode<>("F");

        root.setLeft(B);
        root.getLeft().setDeep(2);
        root.getLeft().setLeft(D);
        root.getLeft().getLeft().setDeep(3);
        root.getLeft().setRight(E);
        root.getLeft().getRight().setDeep(3);

        root.setRight(C);
        root.getRight().setDeep(2);
        root.getRight().setLeft(F);
        root.getRight().getLeft().setDeep(3);

//        TreeNode.preOrder(root);
//        TreeNode.middleOrder(root);
//        TreeNode.postOrder(root);
        System.out.println(TreeNode.getLast(root).getData());
    }

    private static List<String> getList() {
        return Arrays.asList("A", "B", "C", "D", "E", "F");
    }


}
